﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UploadController : ControllerBase
    {

         public UploadController(IWebHostEnvironment web)
        {
            Web = web;
        }


        public IWebHostEnvironment Web { get; }

        [HttpPost]
         public IActionResult Uplo(IFormFile file)
        {
             string nete=Guid.NewGuid().ToString();

              string path=Web.WebRootPath+@"\pic\"+nete+file.FileName;

            using (FileStream fs=System.IO.File.Create(path))
            {
                  file.CopyTo(fs);
                 fs.Close();
            }
            return Ok(@"/pic/" + nete + file.FileName);
        }
    }
}
